package org.gdpu.model;

import javax.persistence.*;

/**
 * Created by HEWI2 on 1/22/14.
 */
@Entity
public class Dormitory {

    /**
     * 标识列
     */
    private int id;
    /**
     * 宿舍编号
     */
    private String dormitoryId;

    /**
     * 男生/女生宿舍
     */
    private Sex sex;
    /**
     * 宿舍状态
     */
    private DormitoryState dormitoryState;
    /**
     * 宿舍已住人数
     */
    private int num;

    /**
     * 校区
     */
    private Campus campus;

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(length = 10, nullable = false)
    public String getDormitoryId() {
        return dormitoryId;
    }

    public void setDormitoryId(String dormitoryId) {
        this.dormitoryId = dormitoryId;
    }

    @Enumerated(EnumType.ORDINAL)
    @Column(nullable = false)
    public Sex getSex() {
        return sex;
    }

    public void setSex(Sex sex) {
        this.sex = sex;
    }

    @Enumerated(EnumType.ORDINAL)
    @Column(nullable = false)
    public DormitoryState getDormitoryState() {
        return dormitoryState;
    }

    public void setDormitoryState(DormitoryState dormitoryState) {
        this.dormitoryState = dormitoryState;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    @ManyToOne
    @JoinColumn(name = "campusId", nullable = false)
    public Campus getCampus() {
        return campus;
    }

    public void setCampus(Campus campus) {
        this.campus = campus;
    }

    public Dormitory(String dormitoryId) {
        super();
        this.dormitoryId = dormitoryId;
    }

    public Dormitory() {
        super();
    }

    @Override
    public String toString() {
        return dormitoryId;
    }
}
